using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

namespace sforceExplorer
{
	/// <summary>
	/// Summary description for DataGridHyperLinkColumn.
	/// </summary>
	public class DataGridSystemFieldColumn : 
		DataGridTextBoxColumn
	{
		int _offSet = 0;

		string _linkLabelText = string.Empty;
		string _label = string.Empty;

		/// <summary>
		/// Creates a new instance of the ExtendedDataGridLinkLabelColumn class.
		/// </summary>
		public DataGridSystemFieldColumn():base()
		{
		}

		/// <summary>
		/// Gets or sets the caption of the label.If empty, the value of the underlying item will be showed.
		/// </summary>
		[DefaultValue("")]
		[Description("The caption of the label. If empty, the value of the underlying item will be showed.")]
		public string LinkLabelText
		{
			get
			{
				return _linkLabelText;
			}
			set
			{
				_linkLabelText = value;
			}
		}

		/// <summary>
		/// Gets or sets the top offset of the text.
		/// </summary>
		[System.ComponentModel.DefaultValue(0)]
		public int OffSet
		{
			get
			{
				return _offSet;
			}
			set
			{
				_offSet = value;
			}
		}

		protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
		{

			Font font = new Font(this.TextBox.Font.FontFamily, this.TextBox.Font.Size, FontStyle.Italic);
			Brush brush = new SolidBrush(Color.Black);
			g.FillRectangle(backBrush, bounds);
			this._label = this.GetColumnValueAtRow(source, rowNum).ToString();
			if(this.LinkLabelText == string.Empty)
				g.DrawString(this.GetColumnValueAtRow(source, rowNum).ToString(), font, brush, bounds.X, bounds.Y + this.OffSet);
			else
				g.DrawString(this.LinkLabelText, font, brush, bounds.X, bounds.Y + this.OffSet);

		}

		protected override void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
		{
			return;
		}

	}

}
